package com.foo;

import javax.inject.Inject;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.request.mapper.parameter.PageParameters;

public class HomePage extends WebPage {
	
	private static final long serialVersionUID = 1L;
	
	@Inject
	private FooStateless foo;
	
	private AjaxButton button;
	private Form<Void> form;

    public HomePage(final PageParameters parameters) {
    	
    	form = new Form<Void>( "form" );
    	
    	button = new AjaxButton( "button" ) {

			@Override
			protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
				foo.foo();
			}

			@Override
			protected void onError(AjaxRequestTarget target, Form<?> form) {
			}
    		
    	};
    	
    	
    	add( form );
    	form.add( button );
    }
}
